<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ECUST课程分享仓库目录</title>
    <script src="https://mirrors.sustech.edu.cn/cdnjs/ajax/libs/showdown/2.1.0/showdown.min.js"></script>
    <style>
        body {
            font-family: Arial, sans-serif;
            max-width: 1000px;
            margin: 0 auto;
            padding: 20px;
        }
        
        /* 搜索相关样式 */
        .search-container {
            margin: 20px 0;
            padding: 15px;
            background: #f8f9fa;
            border-radius: 5px;
            border: 1px solid #e1e4e8;
        }
        
        .search-box {
            display: flex;
            gap: 10px;
            margin-bottom: 10px;
        }
        
        .search-input {
            flex: 1;
            padding: 8px 12px;
            border: 1px solid #e1e4e8;
            border-radius: 4px;
            font-size: 14px;
        }
        
        .search-button {
            padding: 8px 16px;
            background-color: #0366d6;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 14px;
        }
        
        .search-button:hover {
            background-color: #0256b9;
        }
        
        .search-button:disabled {
            background-color: #6c757d;
            cursor: not-allowed;
        }
        
        .search-results {
            margin-top: 20px;
        }
        
        .search-result-item {
            padding: 10px;
            border: 1px solid #e1e4e8;
            border-radius: 4px;
            margin-bottom: 10px;
            background-color: white;
        }
        
        .search-result-path {
            color: #586069;
            font-size: 12px;
            margin-bottom: 5px;
        }
        
        .search-result-name {
            color: #0366d6;
            font-weight: bold;
            font-size: 14px;
            margin-bottom: 5px;
        }
        
        .search-result-size {
            color: #586069;
            font-size: 12px;
        }
        
        .search-loading {
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 20px;
            color: #586069;
            gap: 10px;
        }

        .spinner {
            width: 20px;
            height: 20px;
            border: 2px solid #f3f3f3;
            border-top: 2px solid #3498db;
            border-radius: 50%;
            animation: spin 1s linear infinite;
        }

        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }

        .download-source {
            color: #0366d6;
            text-decoration: none;
            font-size: 12px;
            margin-right: 8px;
        }

        .download-source:hover {
            text-decoration: underline;
        }

        .search-result-item {
            transition: all 0.2s ease;
        }

        .search-result-item:hover {
            box-shadow: 0 2px 8px rgba(0,0,0,0.1);
            transform: translateY(-1px);
        }
        
        .search-error {
            color: #d73a49;
            padding: 10px;
            background-color: #fff5f5;
            border: 1px solid #ffc9c9;
            border-radius: 4px;
            margin-top: 10px;
        }
        
        .no-results {
            text-align: center;
            color: #586069;
            padding: 20px;
        }
        .api-switch {
            margin-top: 10px;
            color: #586069;
        }
        .api-link {
            color: #0366d6;
            text-decoration: none;
        }
        .api-link:hover {
            text-decoration: underline;
        }
        #tree {
            font-family: monospace;
            line-height: 1.5;
            margin-top: 20px;
        }
        .dir {
            color: #0366d6;
            font-weight: bold;
            cursor: pointer;
            position: relative;
            padding-left: 15px;
        }
        .dir::before {
            content: '📁 ';
        }
        .dir.collapsed::before {
            content: '📂 ';
        }
        .file {
            color: #24292e;
            padding-left: 15px;
        }
        .file::before {
            content: '📄 ';
        }
        .loading {
            color: #6a737d;
            font-style: italic;
            padding-left: 30px;
            display: flex;
            align-items: center;
        }
        .error {
            color: red;
        }
        .readme-container {
            margin: 20px 0;
            padding: 15px;
            background: #f5f5f5;
            border-radius: 5px;
            border-left: 4px solid #0366d6;
        }
        .readme-title {
            font-weight: bold;
            margin-bottom: 10px;
            color: #0366d6;
            display: flex;
            align-items: center;
        }
        .readme-content {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
            line-height: 1.5;
            color: #24292e;
            word-wrap: break-word;
            overflow-wrap: break-word;
        }
        .file-link {
            cursor: pointer;
            text-decoration: underline;
            color: #0366d6;
        }
        .download-sources {
            margin-left: 10px;
            font-size: 0.8em;
            color: #586069;
        }
        .download-source {
            margin-left: 8px;
            color: #586069;
            text-decoration: none;
        }
        .download-source:hover {
            text-decoration: underline;
            color: #0366d6;
        }
        
        /* Markdown 渲染样式 */
        .readme-content h1, .readme-content h2, .readme-content h3 {
            margin: 1em 0 0.5em 0;
            color: #0366d6;
        }
        .readme-content h1 {
            font-size: 1.5em;
            border-bottom: 1px solid #eaecef;
            padding-bottom: 0.3em;
        }
        .readme-content h2 {
            font-size: 1.3em;
            border-bottom: 1px solid #eaecef;
            padding-bottom: 0.3em;
        }
        .readme-content h3 {
            font-size: 1.1em;
        }
        .readme-content pre {
            background-color: #f6f8fa;
            border-radius: 3px;
            padding: 16px;
            overflow-x: auto;
            line-height: 1.45;
            white-space: pre-wrap;
            word-wrap: break-word;
        }
        .readme-content code {
            background-color: rgba(27,31,35,0.05);
            border-radius: 3px;
            padding: 0.2em 0.4em;
            font-family: monospace;
        }
        .readme-content ul, .readme-content ol {
            padding-left: 2em;
        }
        .readme-content img {
            max-width: 100%;
            box-sizing: content-box;
            background-color: #fff;
        }
        .readme-content a {
            color: #0366d6;
            text-decoration: none;
        }
        .readme-content a:hover {
            text-decoration: underline;
        }
        .readme-content blockquote {
            padding: 0 1em;
            color: #6a737d;
            border-left: 0.25em solid #dfe2e5;
            margin: 0 0 1em 0;
        }
        .readme-content .center {
            text-align: center;
        }
        .readme-content .note {
            background-color: #e7f5ff;
            border-left: 4px solid #0366d6;
            padding: 1em;
            margin: 1em 0;
        }
        .readme-content .important {
            background-color: #fff3bf;
            border-left: 4px solid #f08c00;
            padding: 1em;
            margin: 1em 0;
        }
        .readme-content .todo-list {
            list-style-type: none;
            padding-left: 0;
        }
        .readme-content .todo-list li {
            margin: 0.5em 0;
            padding-left: 1.5em;
            position: relative;
        }
        .readme-content .todo-list li:before {
            content: "☐";
            position: absolute;
            left: 0;
        }
        .readme-content .todo-list li.checked:before {
            content: "☑";
        }
        .readme-content .badge {
            display: inline-block;
            padding: 0.25em 0.4em;
            font-size: 75%;
            font-weight: 700;
            line-height: 1;
            text-align: center;
            white-space: nowrap;
            vertical-align: baseline;
            border-radius: 0.25rem;
            margin: 0 0.2em;
        }
        
        /* 加载动画 */
        .spinner {
            display: inline-block;
            width: 1em;
            height: 1em;
            border: 2px solid rgba(0, 0, 0, 0.1);
            border-radius: 50%;
            border-top-color: #0366d6;
            animation: spin 1s ease-in-out infinite;
            margin-right: 8px;
            vertical-align: middle;
        }
        @keyframes spin {
            to { transform: rotate(360deg); }
        }
        
        /* 错误样式增强 */
        .readme-container.error {
            border-left-color: #d73a49;
        }
        .error-message {
            color: #d73a49;
            display: flex;
            align-items: center;
            gap: 8px;
        }
        .error-icon {
            font-size: 1.2em;
        }
        .retry-btn {
            margin-left: auto;
            padding: 4px 8px;
            background-color: #f3f4f6;
            border: 1px solid #d1d5da;
            border-radius: 3px;
            cursor: pointer;
        }
        .retry-btn:hover {
            background-color: #eaecef;
        }
        
        /* 目录样式 */
        .toc {
            background: #f8f9fa;
            padding: 10px 15px;
            border-radius: 3px;
            margin-bottom: 15px;
            border: 1px solid #e1e4e8;
        }
        .toc ul {
            list-style: none;
            padding-left: 0;
            margin: 5px 0 0 0;
        }
        .toc li {
            margin: 5px 0;
        }
        .toc-link {
            color: #0366d6;
            text-decoration: none;
        }
        .toc-link:hover {
            text-decoration: underline;
        }
        
        /* 响应式设计 */
        @media (max-width: 768px) {
            body {
                padding: 10px;
            }
            .readme-container {
                padding: 10px;
            }
            .readme-content pre {
                padding: 10px;
                font-size: 0.9em;
            }
            .download-sources {
                display: block;
                margin-left: 0;
                margin-top: 4px;
            }
        }
    </style>
</head>
<body>
    <h1>ECUST课程分享仓库目录</h1>
    
    <!-- 搜索组件 -->
    <div class="search-container">
        <div class="search-box">
            <input type="text" class="search-input" placeholder="搜索课程资源..." id="searchInput">
            <button class="search-button" id="searchButton">搜索</button>
        </div>
        <div id="searchResults" class="search-results"></div>
    </div>
    
    <p>点击目录可以展开查看内容，README文件会自动显示</p>
    <p class="api-switch">
        当前使用CNB API | 
        <a href="github.html" class="api-link">
            切换到 GitHub API版本 🔄
        </a>
    </p>
    
    <div id="tree"></div>
    <div id="readme"></div>

    <script>
        const apiBaseUrl = 'https://cnbapi.bestzyq.cn/ecustcic/ecust-CourseShare/-/git/contents/';

        // 下载源配置，可以在这里添加更多下载源
        const downloadSources = [
            {
                name: "Github源",
                url: "https://github.com/tianyilt/ecust-CourseShare/blob/master/{path}"
            },
            {
                name: "Gitcode源",
                url: "https://gitcode.com/ecust/ecust-CourseShare/blob/master/{path}"
            },
            {
                name: "CNB源",
                url: "https://cnb.cool/ecustcic/ecust-CourseShare/-/blob/master/{path}"
            },
            {
                name: "Alist源",
                url: "http://alist.ecustvr.top/ecust-CourseShare/{path}"
            }
        ];

        // 搜索功能实现
        document.addEventListener('DOMContentLoaded', function() {
            const searchInput = document.getElementById('searchInput');
            const searchButton = document.getElementById('searchButton');
            const searchResults = document.getElementById('searchResults');

            // 执行搜索
            async function performSearch(query) {
                if (!query.trim()) {
                    searchResults.innerHTML = '';
                    return;
                }

                searchButton.disabled = true;
                searchResults.innerHTML = '<div class="search-loading"><div class="spinner"></div>搜索中...</div>';

                try {
                    // 使用Alist API进行搜索
                    const response = await fetch('http://alist.ecustvr.top/api/fs/search', {
                        method: 'POST',
                        headers: {
                            'Content-Type': 'application/json',
                        },
                        body: JSON.stringify({
                            parent: '/',
                            keywords: query,
                            scope: 0,
                            page: 1,
                            per_page: 50,
                            password: ''
                        })
                    });

                    if (!response.ok) {
                        throw new Error('搜索请求失败');
                    }

                    const data = await response.json();
                    
                    if (!data.data || !data.data.content || data.data.content.length === 0) {
                        searchResults.innerHTML = '<div class="no-results">未找到相关资源</div>';
                        return;
                    }

                    // 生成搜索结果HTML
                    const resultsHtml = data.data.content.map(result => {
                        const isDir = result.is_dir;
                        const parentPath = result.parent.replace(/^\/Public\/ecust-CourseShare\//, '');
                        const path = parentPath + '/' + result.name;
                        const size = isDir ? '文件夹' : formatFileSize(result.size);
                        const icon = isDir ? '📁' : '📄';

                        // 生成下载源链接
                        const downloadLinks = downloadSources.map((source, index) => {
                            const sourceUrl = source.url.replace('{path}', path);
                            return `<a href="${sourceUrl}" target="_blank" class="download-source">${source.name}</a>`;
                        }).join(' | ');

                        return `
                            <div class="search-result-item">
                                <div class="search-result-path">${path}</div>
                                <div class="search-result-name">
                                    ${icon} <a href="https://cnb.cool/ecustcic/ecust-CourseShare/-/git/raw/master/${path}" 
                                       target="_blank">${result.name}</a>
                                </div>
                                <div class="search-result-size">
                                    ${size}
                                    <span class="download-sources">
                                        下载源: ${downloadLinks}
                                    </span>
                                </div>
                            </div>
                        `;
                    }).join('');

                    searchResults.innerHTML = resultsHtml;

                } catch (error) {
                    searchResults.innerHTML = `
                        <div class="search-error">
                            搜索出错：${error.message}
                        </div>
                    `;
                    console.error('搜索错误:', error);
                } finally {
                    searchButton.disabled = false;
                }
            }

            // 文件大小格式化函数
            function formatFileSize(bytes) {
                if (bytes === 0) return '0 B';
                const k = 1024;
                const sizes = ['B', 'KB', 'MB', 'GB', 'TB'];
                const i = Math.floor(Math.log(bytes) / Math.log(k));
                return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + ' ' + sizes[i];
            }

            // 搜索按钮点击事件
            searchButton.addEventListener('click', () => {
                const query = searchInput.value;
                performSearch(query);
            });

            // 回车键触发搜索
            searchInput.addEventListener('keypress', (e) => {
                if (e.key === 'Enter') {
                    const query = searchInput.value;
                    performSearch(query);
                }
            });
        });

        document.addEventListener('DOMContentLoaded', () => {
            loadDirectory('.', 'tree');
        });

        async function loadDirectory(path, targetElementId, parentElement = null) {
            const targetElement = parentElement || document.getElementById(targetElementId);
            const loadingElement = document.createElement('div');
            loadingElement.className = 'loading';
            loadingElement.innerHTML = '<div class="spinner"></div>加载中...';
            
            if (parentElement) {
                targetElement.appendChild(loadingElement);
            } else {
                targetElement.innerHTML = '';
                targetElement.appendChild(loadingElement);
                document.getElementById('readme').innerHTML = '';
            }

            try {
                const contents = await fetchDirectoryContents(path);
                const sortedContents = sortContents(contents);
                displayDirectoryContents(sortedContents, targetElement, loadingElement, path);
                
                if (path === '.') {
                    const readme = findReadme(contents);
                    if (readme) {
                        displayReadme(readme);
                    }
                }
            } catch (error) {
                const errorElement = document.createElement('div');
                errorElement.className = 'error';
                errorElement.textContent = `加载失败: ${error.message}`;
                targetElement.replaceChild(errorElement, loadingElement);
                console.error(error);
            }
        }

        function sortContents(contents) {
            return contents.sort((a, b) => {
                if (a.type === 'dir' && b.type !== 'dir') return -1;
                if (a.type !== 'dir' && b.type === 'dir') return 1;
                
                // 检查是否包含英文字母
                const aHasEnglish = /[a-zA-Z]/.test(a.name);
                const bHasEnglish = /[a-zA-Z]/.test(b.name);
                
                // 如果一个是英文，一个不是英文，英文优先
                if (aHasEnglish && !bHasEnglish) return -1;
                if (!aHasEnglish && bHasEnglish) return 1;
                
                // 如果都是英文或都不是英文，使用原来的排序方式
                return a.name.localeCompare(b.name, 'zh-Hans-CN', {numeric: true});
            });
        }

        function findReadme(contents) {
            return contents.find(item => 
                item.type === 'file' && /readme\.md$/i.test(item.name)
            );
        }

        async function fetchDirectoryContents(path) {
            const url = `${apiBaseUrl}${path}`;
            const response = await fetch(url);
            
            if (!response.ok) {
                throw new Error(`API请求失败: ${response.status} ${response.statusText}`);
            }
            
            const data = await response.json();
            
            if (data.type === 'tree' && data.entries) {
                return data.entries.map(entry => ({
                    name: entry.name,
                    type: entry.type === 'tree' ? 'dir' : 'file',
                    path: entry.path,
                    sha: entry.sha,
                    html_url: `https://cnb.cool/ecustcic/ecust-CourseShare/-/git/raw/master/${entry.path}`
                }));
            }
            
            throw new Error('无效的API响应格式');
        }

        function renderMarkdown(content) {
            const converter = new showdown.Converter({
                tables: true,
                tasklists: true,
                strikethrough: true,
                emoji: true,
                underline: true,
                metadata: true,
                openLinksInNewWindow: true,
                ghCompatibleHeaderId: true,
                ghMentions: true,
                ghMentionsLink: 'https://github.com/{u}',
                encodeEmails: true,
                backslashEscapesHTMLTags: true,
                completeHTMLDocument: false,
                splitAdjacentBlockquotes: true,
                simpleLineBreaks: true,
                requireSpaceBeforeHeadingText: true,
                ghCodeBlocks: true,
                tablesHeaderId: true,
                parseImgDimensions: true,
                excludeTrailingPunctuationFromURLs: true,
                literalMidWordUnderscores: true,
                literalMidWordAsterisks: true,
                smoothLivePreview: true,
                smartIndentationFix: true,
                disableForced4SpacesIndentedSublists: true
            });

            // 添加自定义扩展
            converter.addExtension({
                type: 'lang',
                regex: /> \[!NOTE\]\n>([\s\S]*?)(?=\n\n|$)/g,
                replace: (match, content) => {
                    // 移除所有 > 符号和后面的空格
                    content = content.replace(/^>\s*/gm, '');
                    // 移除开头的空行
                    content = content.replace(/^\n+/, '');
                    // 让 Showdown 处理内容
                    content = converter.makeHtml(content);
                    return `<div class="note">
                        <div class="note-header">
                            <span class="note-icon">📝</span>
                            <span class="note-title">注意</span>
                        </div>
                        <div class="note-content">${content}</div>
                    </div>`;
                }
            }, 'note-block');

            converter.addExtension({
                type: 'lang',
                regex: /> \[!IMPORTANT\]\n>([\s\S]*?)(?=\n\n|$)/g,
                replace: (match, content) => {
                    // 移除所有 > 符号和后面的空格
                    content = content.replace(/^>\s*/gm, '');
                    // 移除开头的空行
                    content = content.replace(/^\n+/, '');
                    // 让 Showdown 处理内容
                    content = converter.makeHtml(content);
                    return `<div class="important">
                        <div class="important-header">
                            <span class="important-icon">⚠️</span>
                            <span class="important-title">重要</span>
                        </div>
                        <div class="important-content">${content}</div>
                    </div>`;
                }
            }, 'important-block');

            // 添加样式
            const style = document.createElement('style');
            style.textContent = `
                .note, .important {
                    margin: 1em 0;
                    padding: 1em;
                    border-radius: 4px;
                }
                .note {
                    background-color: #e7f5ff;
                    border-left: 4px solid #0366d6;
                }
                .important {
                    background-color: #fff3bf;
                    border-left: 4px solid #f08c00;
                }
                .note-header, .important-header {
                    display: flex;
                    align-items: center;
                    margin-bottom: 0.5em;
                    font-weight: bold;
                }
                .note-icon, .important-icon {
                    margin-right: 0.5em;
                    font-size: 1.2em;
                }
                .note-title {
                    color: #0366d6;
                }
                .important-title {
                    color: #f08c00;
                }
                .note-content, .important-content {
                    margin: 0;
                }
                .note-content p, .important-content p {
                    margin: 0.5em 0;
                }
                .note-content p:first-child, .important-content p:first-child {
                    margin-top: 0;
                }
                .note-content p:last-child, .important-content p:last-child {
                    margin-bottom: 0;
                }
            `;
            document.head.appendChild(style);

            // 转换 Markdown
            let html = converter.makeHtml(content);

            // 处理图片
            html = html.replace(/<img src="([^"]+)" alt="([^"]+)"(?: title="([^"]+)")?>/g, (match, src, alt, title) => {
                if (src.startsWith('readme.assets/')) {
                    // 处理相对路径的图片
                    return `<img src="/${src}" alt="${alt}"${title ? ` title="${title}"` : ''}>`;
                }
                return match;
            });

            // 生成目录
            const headings = html.match(/<h[1-3][^>]*>([^<]+)<\/h[1-3]>/g);
            let toc = '';
            if (headings && headings.length > 2) {
                toc = '<div class="toc"><strong>目录</strong><ul>';
                headings.forEach(heading => {
                    const level = heading.match(/<h([1-3])/)[1];
                    const title = heading.match(/>([^<]+)</)[1];
                    const id = title.toLowerCase().replace(/[^\w\u4e00-\u9fa5]+/g, '-');
                    toc += `<li style="margin-left: ${(level - 1) * 15}px">
                              <a href="#${id}" class="toc-link">${title}</a>
                           </li>`;
                });
                toc += '</ul></div>';
            }
            
            return toc + '<div class="markdown-body">' + html + '</div>';
        }

        async function displayReadme(readme) {
            const readmeContainer = document.getElementById('readme');
            readmeContainer.innerHTML = `
                <div class="readme-container">
                    <div class="readme-title">📝 ${readme.name}</div>
                    <div class="loading">
                        <div class="spinner"></div>
                        加载README内容中...
                    </div>
                </div>
            `;
            
            try {
                const response = await fetch(`https://cnb.ecustvr.top/ecustcic/ecust-CourseShare/-/git/raw/master/${readme.path}`);
                
                if (!response.ok) {
                    throw new Error(`HTTP错误: ${response.status}`);
                }
                
                const content = await response.text();
                
                readmeContainer.innerHTML = `
                    <div class="readme-container">
                        <div class="readme-title">📝 ${readme.name} 
                            <a href="${readme.html_url}" target="_blank" style="font-size: 0.8em; margin-left: 10px;">(查看原文)</a>
                        </div>
                        <div class="readme-content">${renderMarkdown(content)}</div>
                    </div>
                `;
            } catch (error) {
                readmeContainer.innerHTML = `
                    <div class="readme-container error">
                        <div class="readme-title">📝 ${readme.name}</div>
                        <div class="error-message">
                            <span class="error-icon">❌</span>
                            无法加载README内容: ${error.message}
                            <button class="retry-btn" onclick="displayReadme(${JSON.stringify(readme).replace(/"/g, '&quot;')})">重试</button>
                        </div>
                    </div>
                `;
            }
        }

        function displayDirectoryContents(contents, targetElement, loadingElement, currentPath) {
            const container = document.createElement('div');
            targetElement.replaceChild(container, loadingElement);

            contents.forEach(item => {
                const itemElement = document.createElement('div');
                
                if (item.type === 'dir') {
                    itemElement.className = 'dir collapsed';
                    itemElement.textContent = item.name;
                    
                    itemElement.addEventListener('click', function(e) {
                        e.stopPropagation();
                        
                        if (this.classList.contains('expanded')) {
                            this.classList.remove('expanded');
                            this.classList.add('collapsed');
                            const childContainer = this.nextElementSibling;
                            if (childContainer) {
                                childContainer.remove();
                            }
                        } else {
                            this.classList.remove('collapsed');
                            this.classList.add('expanded');
                            
                            const childContainer = document.createElement('div');
                            childContainer.style.marginLeft = '20px';
                            this.parentNode.insertBefore(childContainer, this.nextSibling);
                            
                            loadDirectory(item.path, '', childContainer);
                            
                            const readme = findReadme(contents);
                            if (readme && readme.path.startsWith(item.path)) {
                                displayReadme(readme);
                            }
                        }
                    });
                } else {
                    itemElement.className = 'file';
                    const link = document.createElement('a');
                    link.className = 'file-link';
                    link.textContent = item.name;
                    link.href = item.html_url;
                    link.target = '_blank';
                    itemElement.appendChild(link);
                    
                    // 添加下载源链接
                    if (downloadSources.length > 0) {
                        const sourcesContainer = document.createElement('span');
                        sourcesContainer.className = 'download-sources';
                        sourcesContainer.textContent = '下载源: ';
                        
                        downloadSources.forEach((source, index) => {
                            const sourceLink = document.createElement('a');
                            sourceLink.className = 'download-source';
                            sourceLink.textContent = source.name;
                            sourceLink.href = source.url.replace('{path}', item.path);
                            sourceLink.target = '_blank';
                            sourceLink.title = source.url.replace('{path}', item.path);
                            
                            if (index > 0) {
                                sourcesContainer.appendChild(document.createTextNode(' | '));
                            }
                            sourcesContainer.appendChild(sourceLink);
                        });
                        
                        itemElement.appendChild(sourcesContainer);
                    }
                    
                    // 只有在非根目录时才显示README
                    if (/readme\.md$/i.test(item.name) && currentPath !== '.') {
                        displayReadme(item);
                    }
                }
                
                container.appendChild(itemElement);
            });
        }
    </script>
</body>
</html>